import request from '../../router/axios'

export function fetchList(query) {
  return request({
    url: '/admin/dict/page',
    method: 'get',
    params: query
  })
}

export function fetchItemList(query) {
  return request({
    url: '/admin/dict/item/page',
    method: 'get',
    params: query
  })
}

export function addItemObj(obj) {
  return request({
    url: '/admin/dict/item',
    method: 'post',
    data: obj
  })
}

export function getItemObj(id) {
  return request({
    url: '/admin/dict/item/' + id,
    method: 'get'
  })
}

export function delItemObj(id) {
  return request({
    url: '/admin/dict/item/' + id,
    method: 'delete'
  })
}

export function putItemObj(obj) {
  return request({
    url: '/admin/dict/item',
    method: 'put',
    data: obj
  })
}

export function addObj(obj) {
  return request({
    url: '/admin/dict/',
    method: 'post',
    data: obj
  })
}

export function getObj(id) {
  return request({
    url: '/admin/dict/' + id,
    method: 'get'
  })
}

export function delObj(row) {
  return request({
    url: '/admin/dict/' + row.id,
    method: 'delete'
  })
}

export function putObj(obj) {
  return request({
    url: '/admin/dict/',
    method: 'put',
    data: obj
  })
}

export function remote(params) {
  return request({
    // url: '/admin/sys/param/item/list',
    url: '/admin/sys/param/item/list/enabled',
    method: 'get',
    params
  })
}

export function getType(params) {
  return request({
    url: '/admin/dict/type/dict_type',
    method: 'get',
    params
  })
}

export function getIdByTableName(tableName) { // 根据表名查询对应的业务资源实体ID
  return request({
    url: '/admin/busiFunction/tableFunc/' + tableName,
    method: 'get'
  })
}

// 获取国际化语言选项
export function getLang(router) {
  return request({
    url: '/admin/commonconfig/locale/list',
    method: 'get'
  })
}

// 更换语言
export function setLang(router, locale, username) {
  return request({
    url: '/admin/sysi18n/language/change',
    method: 'post',
    params: {
      locale,
      username
    }
  })
}

export const getCommonPression = type => request({ // 查询常用语
  url:'/admin/commonexpression/list',
  method:'get',
  params:{
    type
  }
})

export const getSignLoginUser = () => request({ // 获取当前登录用户的签名
  url:'/admin/usersignature/loggeduser',
  method:'get'
})